from appium.webdriver.common.appiumby import By
from time import sleep
import logging
import sys

sys.path.append(r'..')
from common.common_fun import Common
from common.desired_caps import desired_caps


class LoginPage(Common):
    username_loc = (By.ID, 'com.tal.kaoyan:id/login_email_edittext')
    password_loc = (By.ID, 'com.tal.kaoyan:id/login_password_edittext')
    login_btn_loc = (By.ID, 'com.tal.kaoyan:id/login_login_btn')

    def __init__(self, driver):
        super().__init__(driver)

    def login(self, username, password):
        logging.info('login start...')
        self.check_cancel()
        self.check_skip()
        self.input_ele(self.username_loc, username)
        self.input_ele(self.password_loc, password)
        self.ele_click(self.login_btn_loc)
        sleep(3)


# if __name__ == '__main__':
#     username = 'ammyxh01'
#     password = 'ammyxh01'
#
#     driver = desired_caps()
#     login = Login(driver)
#     login.login(username, password)
#
#     driver.quit()
